<?php
class Page_model extends CI_Model
{
    public function __construct()
    {
        $this->load->database();
    }

    public function getAll($param = NULL, $cur_page = 0, $page_num = 10)
    {
        $this->db->from("v_page");
        if (isset($param)) {
            foreach ($param as $k => $v) {
                $this->db->like($k, $v);
            }
        }
        $this->db->order_by("p_public_time", "DESC");
        $this->db->limit($page_num, $page_num * $cur_page);
        $query = $this->db->get();
        return $query->result_array();
    }

    public function getCount($param = NULL)
    {
        $this->db->from("v_page");
        if (isset($param)) {
            foreach ($param as $k => $v) {
                $this->db->like($k, $v);
            }
        }
        $num = $this->db->count_all_results();
        return $num;
    }
}
?>